/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ipti.br.tag.entity;

import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import org.ipti.br.tag.util.EncryptionUtil;

/**
 *
 * @author root
 */

@Entity
public class Discipline extends AbstractEntity{

    @Column(length=50)
    private String name;
    
    @OneToMany(mappedBy = "discipline")
    private List<UnitySchedule> unitySchedules;

    public Discipline() {
    }

    @Override
    public void generateHash(){
        if(getId() == null){
            String hash = "" + this.getName();
            this.setId(Long.valueOf(EncryptionUtil.encrypt(hash).hashCode()));
        }
    }

    public Discipline(String name) {
        this.name = name;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<UnitySchedule> getUnitySchedules() {
        return unitySchedules;
    }

    public void setUnitySchedules(List<UnitySchedule> unitySchedules) {
        this.unitySchedules = unitySchedules;
    }

    @Override
    public String toString() {
        return "Discipline{" + "id=" + this.getId() + '}';
    }
}
